Third quiz: November 20th 
Material: Up to this coming Thursday's material (The post-exam topics)

- Stack
LIFO data structure
Abstract Data Type (ADT): stack interface will consist of the following methods: 
size, isEmpty, push, pop, top

If stack full => push throws an exception
If stack empty => pop and top throw an exception

- Plan: 
1) Create our own stack data structure

1.a) Create the stack ADT
1.b) Create an exception class
1.c) Create a class implementing the ADT: ArrayBasedStack ---> array + top element index
1.d) Test the class
1.e) Use the class to solve the problem at hand.

2) Use it to solve the grouping symbol matching problem

([{: opening
)]}: closing

() Valid; ([)] Invalid; ([]) Valid;  Valid; 1 + 2 Valid

2.a) Every time we encounter an opening symbol: push it onto the stack  
2.b) Whenever we encounter a closing symbol: 
Contrast it with the top element (if any) ---> 
case#1: stack is empty --> return false
case#2: opening and closing are not of the same nature --> return false
case#3: removing the existing top element 

----------------------------------------------------------------------------
Queue: 
FIFO (First In First Out) data strucutre

ADT: 
int size()
boolean isEmpty()

void enqueue(Object element) throws QueueException
Object dequeue() throws QueueException
Object top() throws QueueException

Option#1:

Use an array to hold the elements of the queue
If queue has n elements => n elements occupy positions 0 through n - 1

Let the element at 0 be the front of the queue

Removing the first element (dequeue) requires O(n) time

Option#2: 
Let the rear element occupy the first position of the queue
enqueue requires O(n) time

Option#3:
Use two pointers to keep track: 
1) Front : index of the front element of the queue
2) Rear: index of the next available cell

        front   rear
0	1	2
null	4






































